1. Field of the Invention
The present invention relates to a method and an apparatus for auto-tracking and compensating the clock frequency and, more particularly, to a method and an apparatus for auto-tracking and compensating the clock frequency for the USB (Universal Serial Bus) peripheral.
2. The Related Arts
The USB ports of a computer are capable of plugging a plurality of USB peripherals, including USB keyboard, USB mouse, USB card reader, USB flash drive, external USB hard disk, USB printer, and USB scanner, etc, so as to facilitate the users. The transmission speed of USB has also evolved from the 1.5 Mbps or 12 Mbps of USB 1.1 to the recent 480 Mbps of USB 2.0.
According to the specification of the USB, USB 1.1 can support low speed peripherals, such as USB keyboard, USB mouse, and USB joy stick, whose transmission speed is 1.5 Mbps with the tolerance of 1.5%, and the full speed peripherals, such as USB flash drive, USB printer, and USB scanner, whose transmission speed is 12 Mbps with a tolerance of 0.25%. On the other hand, USB 2.0 is capable of supporting high speed peripherals, whose transmission speed is as high as 480 Mbps. USB 2.0 is downward compatible with the USB1.1, and therefore, USB 2.0 can support low speed, full speed and high speed peripherals.
FIG. 1 of the attached drawings shows a block diagram of a conventional USB low speed controller. The USB low speed controller 100 normally requires an external precise crystal oscillator 120, or a ceramic resonator, and external large-capacitance capacitors C1 and C2 to cooperate with its internal oscillating auxiliary circuit 101 to generate the CLK clock signal for the internal clock extracting circuit 102 inside the low speed controller 100. For example, the CLK clock frequency is 6 MHz, which is the four times (4×) sampling frequency for USB low speed. The crystal oscillator can be oscillated at 1.5 MHz clock frequency and 6 MHz of 4× sampling frequency is obtained by frequency-multiplying the same utilizing a phase lock loop (PLL). The transceiver 101 is coupled to the USB port of the host. The transceiver 104 receives a data stream through a differential signal pair of D+/D−. When the transceiver 104 receives the differential signal D+/D− from the host, it outputs the differential signal RXD+/RXD− and associated NRZI-coded RXD data signal to the serial interface engine (SIE) 106. The NRZI-coded RXD data is also transmitted to the clock extracting circuit 102. The clock extracting circuit 102 uses the CLK clock to oversample the RXD data, and extract the 1.5 MHz SIECLK clock inherent in the differential signal to operate the SIE 106. The SIE 106 uses the SIECLK clock to recover the RXD data signal to the digital signal. Alternatively, the transceiver 104 receives the differential signal TXD+/TXD− from the SIE 106, and transmits the signal to the host, wherein SIE 106 also controls the transceiver 104. The external crystal oscillator or the ceramic resonator is a considerable expense for the USB mouse manufacturers.
The USB specification includes several types of packets to facilitate all types of transactions. FIG. 2 shows the data format of a token packet 200. The token packet 200 comprises a PID field 220, an ADDR field 240, an ENDP field 260, and a CRC5 field 280. Typically, the width of the PID field 220 is 8 bits, for indicating the packet format, such as, IN, OUT, or SETUP packet. The ADDR field 240 and the ENDP field 260 uniquely indicate the endpoint address. The CRC5 field 280 is a 5-bit cyclic redundant code. The host can use the token packet 200 to inform the endpoint whether a read or a write transaction is performed. If it is a write transaction, the host will send data packets to the endpoint. If read transaction, the endpoint will send data packets to the host.